package dse.messages.singleversion;

import dse.DataObject;
import dse.Experiment;
import dse.ExperimentRecorder;
import dse.messages.Message;
import dse.messages.MessageHandler;
import dse.messages.MessageSender;

public class NegativeRequestShareForeignResponseMessageHandler
extends MessageSender
implements MessageHandler
{
	private DataObject dobj;
	private int shareIndex;
	private ShareDownloader shareDownloader;
	


	public NegativeRequestShareForeignResponseMessageHandler (
			Experiment experiment, 
			DataObject dobj, 
			int shareIndex,
			ShareDownloader shareDownloader
			)
	{
		super(experiment);
		
		this.dobj = dobj;
		this.shareIndex = shareIndex;
		this.shareDownloader = shareDownloader;
	}
	

	
	public boolean acceptMessage (
			Message message
			)
	{
		return true;
	}
	
	public void messageReceived (
			ExperimentRecorder recorder, 
			Message message,
			double timeLeft
			)
	{
		recorder.debug(this, "msgRcvd: " + message, timeLeft);
		shareDownloader.shareDownloadFailed(
				recorder, dobj, shareIndex, timeLeft
				);
	}
	

	public void messageInterupted (
			ExperimentRecorder recorder,
			Message message, 
			double timeLeft
			)
	{
		recorder.debug(this, "msgIntrpt: " + message, timeLeft);
		shareDownloader.shareDownloadFailed(
				recorder, dobj, shareIndex, timeLeft
				);
	}

}
